import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from 'vite-plugin-mock'

import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
// https://vite.dev/config/
export default defineConfig(({ command }) => {
  return {
    plugins: [vue(),
    viteMockServe({
      enable: command === 'serve'
    }),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      symbol: 'icon-[dir]-[name]'
    }),

    ],
    resolve: {
      alias: {
        "@": path.resolve("./src")
      }
    },
    //scss全局变量
    css: {
      preprocessorOptions: {
        scss: {
          silenceDeprecations: ["legacy-js-api"],

          // javascriptEnabled: true,
          // api: 'modern-compiler',
          // addtionalData: `@import "@/styles/variable.scss" ;`
        },
        sass: {
          silenceDeprecations: ["legacy-js-api"],
        }
      }
    }
  }
})
